/**
 * The search results view.
 *
 * (c) Copyright 2011 Nokia Corporation. All rights reserved.
 */

import QtQuick 1.1
import com.nokia.symbian 1.1

Page {
    id: resultsView;

    property alias resultsBetaView: resultsBetaView;

    tools: ToolBarLayout {
         ToolButton {
             iconSource: "toolbar-back";
             onClicked: {
                 busyIndicator.opacity = 0;
                 busyIndicator.running = false;
                 resultsView.pageStack.pop();
                 // Workaround for bug QTCOMPONENTS-1178
                 // (https://bugreports.qt.nokia.com/browse/QTCOMPONENTS-1178).
                 // When the bug is fixed, this function call is no longer
                 // needed.
                 resultsView.pageStack.currentPage.updateToolBarHighlight();
             }
         }
    }

    BetaView {
        id: resultsBetaView;

        anchors {
            fill: parent;
            leftMargin: 10;
            rightMargin: 10;
        }

        Component.onCompleted: {
            getLatest();
        }

        onItemClicked: {
            if (!resultsView.pageStack.busy) {
                // Show the details view for the selected beta application
                var detailsPage = resultsView.pageStack.push(
                        Qt.resolvedUrl("DetailsView.qml"),
                        { betaId: id });
                detailsPage.fetchDetails(id);
            }
        }
    }
}
